#include<stdio.h>
#include <malloc.h>
struct node {
	int num;
	struct node* next;
};
typedef struct node* List;
struct node* creatList()
{
	List p, h;
	List node = (List)malloc(sizeof(struct node));
	p = h = node;
	scanf("%d", &node->num); node->next = NULL;
	if (node->num == -1) return h;

	while (p->num != -1)
	{
		List node = (struct node*)malloc(sizeof(struct node));
		scanf("%d", &node->num); node->next = NULL;
		p->next = node;
		p = p->next;
	}
	return h;
}
List s3(List h1, List h2)
{
	List  p1 = h1, p2 = h2, p3;
	List p = (List)malloc(sizeof(struct node));
	if (p1->num == -1) { p = p2; p2 = p2->next; }
	else if (p2->num == -1) { p = p1; p1 = p1->next; }
	else if (p1->num > p2->num) { p = p2; p2 = p2->next; }
	else
	{
		p = p1; p1 = p1->next;

	}
	p3 = p;
	while (p2->num != -1 || p1->num != -1)
	{
		List New = (List)malloc(sizeof(struct node));
		if (p1->num == -1)
		{
			New = p2;
			p->next = New;
			p2 = p2->next;
		}
		else if (p2->num == -1)
		{
			New = p1;
			p->next = New;
			p1 = p1->next;
		}
		else
		{
			if (p1->num < p2->num)
			{
				New = p1;
				p->next = New;
				p1 = p1->next;
			}
			else
			{
				New = p2;
				p->next = New;
				p2 = p2->next;
			}
		}
		p = p->next;
	}
	p->next = NULL;
	return p3;
}
void Print(List h)
{
	List p = h;
	for (; p->next != NULL; p = p->next)
		printf("%d ", p->num);
	printf("%d", p->num);
}
int main()
{
	int n = 0, m = 0;
	List p;
	List h1 = creatList();
	List h2 = creatList();
	if (h1->num == -1 && h2->num == -1)
	{
		printf("NULL"); return 0;
	}
	List h3 = s3(h1, h2);
	Print(h3);
	return 0;
}